/**
 * @author peter
 * The File class manages all editors for the loaded file, as well as hold the raw content.
 * Whenever an editor is added to the file, it sets itself as the callback, so that the editor can
 * push any changes out to the file, which then reciprocates the change to the rest of the editors.
 * 
 * The File is created by the framework in response to a callback from a resource that a file is being loaded.
 */

dojo.provide("bunkai.bk_file");
dojo.declare("bunkai.bk_file", null,
{
	constructor: function(id, data, cb, resource_id, editorpane)
	{
		this.id = id;
		this.data = data;
		this.callback = cb;
		this.resource_id = resource_id;
		this.editorpane = editorpane;
	},
	
	editorpane: "", // Where to tell our editors to tuck their visuals
	editors: [], 	// The editors which this file has open
	data: "", 		// The raw data that the file contains
	id: "", 		// A unique id, which defines the file in the resource it was loaded from
	callback: "", 	// Callback to the framework so that we can reciprocate file changes back to resource
	resource_id: "",// The name of the resource the file's content was loaded from
	
	
	// Callback from an editor
	contentChanged: function(data)
	{
		this.data = data;
		this.updateAllEditors(this.data);
		this.callback.resourceSaveFile(this.id, this.data, this.resource_id);
	},
	
	addEditor : function(editor)
	{
		editor.setCallback(this);
		editor.setData(this.data);
		editor.setPane(this.editorpane);
		editor.push(editor);	
			
	}	
	
		
})
